/**
 * Copyright (c) 2011 eelpo.com
 * All rights reserved.
 */
package com.eelpo.cmmp.core.wicket.component.tree;

import org.apache.wicket.Component;
import org.apache.wicket.Page;
import org.apache.wicket.PageMap;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;

/**
 * <pre>
 * 
 * 树控件链接面板
 * 
 * </pre>
 * 
 * @author <a href="mailto:Brian@eelpo.com">汪洪州</a>
 * @since 1.0
 */
public class LinkMenuPanel extends Panel {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 936423936820043060L;

	public LinkMenuPanel(String id, Class<Page> pageClass, final IModel<Object> model) {
		super(id);

		addComponents(pageClass, model);
	}

	protected void addComponents(final Class<Page> pageClass, final IModel<Object> model) {

		BookmarkablePageLink<Page> link = new BookmarkablePageLink<Page>("contentLink", pageClass);

		link.setPageMap(PageMap.forName("bodyRight"));

		link.add(newContentComponent("content", model));

		add(link);
	}

	protected Component newContentComponent(String componentId, IModel<Object> model) {
		return new Label(componentId, new PropertyModel<Object>(model.getObject(), "userObject.name"));
	}
}
